<!DOCTYPE html>
<%@ page language="java" import="com.compuvest.web.*" pageEncoding="UTF-8" %>

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<fmt:setBundle basename="properties.Compuvest" var="cv" scope="page" />

<jsp:useBean id="sb" class="SQLBean" scope="application"/>
<jsp:useBean id="advertShow" class="AdvertShow" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    Customer cust = basket.getCustomer();
    if(cust == null) {
	response.sendRedirect(/*application.getInitParameter("https") +*/ "./ResellerForm.jsp");
	return;
    }

    String vpassword = request.getParameter("vPassword") == null ? cust.getPassword() : request.getParameter("vPassword");
    String mode = request.getParameter("mode");
    if(mode != null && mode.equals("Send Form")) {

	cust.setResellerCode(request.getParameter("resellerCode"));
	cust.setPassword(request.getParameter("Password"));
	cust.setNotice(request.getParameter("notice"));
	cust.getBilling().setCompany(request.getParameter("billingCompany"));
	cust.getBilling().setFirstName(request.getParameter("billingFirstName"));
	cust.getBilling().setLastName(request.getParameter("billingLastName"));
	cust.getBilling().setAddress1(request.getParameter("billingAddress1"));
	cust.getBilling().setAddress2(request.getParameter("billingAddress2"));
	cust.getBilling().setCity(request.getParameter("billingCity"));
	cust.getBilling().setCountry(request.getParameter("billingCountry"));
	cust.getBilling().setState(request.getParameter("billingState"));
	cust.getBilling().setZip(request.getParameter("billingZip"));
	cust.getBilling().setZip4(request.getParameter("billingZip4"));
	cust.getBilling().setPhone(request.getParameter("billingPhone"));
	cust.getBilling().setCell(request.getParameter("billingCell"));
	cust.getBilling().setFax(request.getParameter("billingFax"));

	// update database
	basket.setCustomer(cust);

	if(!cust.getResellerCode().isEmpty() && !cust.getPassword().isEmpty() && !cust.getBilling().getFirstName().isEmpty() && !cust.getBilling().getLastName().isEmpty() &&
            !cust.getBilling().getAddress1().isEmpty() && !cust.getBilling().getCity().isEmpty() && !cust.getBilling().getState().isEmpty() &&
            !cust.getBilling().getZip().isEmpty() && !cust.getBilling().getCountry().isEmpty() && !cust.getBilling().getPhone().isEmpty()) {

            response.sendRedirect(/*application.getInitParameter("https") +*/ "./ResellerSendForm.jsp");
            return;
	}
    }
%>
<html>
<head>
<title><fmt:message key='webcorp' bundle='${cv}'/> Reseller</title>
<%@include file="./incl/scripts.txt" %>
</head>
<body>

<div id='cvbody'>

 <head:show />

 <div id='cvcont'>
  <table id='cvmain'>
  <colgroup><col width='80px'/><col width='*'/><col width='80px'/></colgroup>
  <tbody>
   <tr>
    <td id='cvleft' valign="top">

<div style='font:bold 16pt Arial;color:#002e5b;'>Reseller Account</div>
<br/>
<div style='width:85%;background:white;'>
<fieldset>
<div style='padding:15px 15px;text-align:justify;font:normal 10pt arial;'>
 &nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='webcorp' bundle='${cv}'/> invites resellers to do business with us. All discounts are based on
 quantity of purchased goods and a payment method used.<br/>
 &nbsp;&nbsp;&nbsp;&nbsp;Due to commodity nature of our business, we cannot offer a fixed discount on the products we sell.
 Please call or e-mail us with your purchase request, and we will provide you with the best possible price at a given time.<br/><br/>

<b>Reseller Benefits:</b><br/>
 &nbsp;&nbsp;&#x95; Blind Drop shipments directly to your customer<br/>
 &nbsp;&nbsp;&#x95; Dedicated <fmt:message key='webcorp' bundle='${cv}'/> sales representative for all questions and concerns<br/>
 &nbsp;&nbsp;&#x95; Net Terms - additional rules apply, ask your agent how to qualify<br/><br/>

<b>Rules for Resellers:</b><br/>
 &nbsp;&nbsp;&#x95; We require a business license or a Reseller Certificate with full contact information to be faxed to us in order
 to set up a reseller account.<br/><br/>

<b>International Resellers:</b><br/>
 &nbsp; <i>Payment methods:</i><br/>
 &nbsp;&nbsp;&#x95; All Countries - Western Union, Wire Transfer or American Express (Visa and Master card are not accepted).<br/>
 &nbsp;&nbsp;&#x95; Canada - Western Union, Wire Transfer, American Express, Visa or Master card.<br/>
 &nbsp;&nbsp;&#x95; Please visit our
 <a href="<%= "./info/" /*application.getInitParameter("info")*/ %>Payment.jsp">payments section</a>
 for more information on how to make the payment correctly.<br/><br/>
 For resellers who would like to apply for COD or NET terms, please fill out the application
 <a href="<%= "./" /*application.getInitParameter("http")*/ %>img/form/reseller.rtf" style="color:blue;text-decoration:none;"><b>form</b></a>
 and fax to (425) 251-5000.
 </div>
</fieldset>
</div>
<br/>

<form id='Customer' action='<%= "./" /*application.getInitParameter("https")*/ %>Reseller.jsp' onSubmit='return resisDone(this);' enctype='application/x-www-form-urlencoded' method='POST'>
<div style='width:40%;'>
<fieldset>
<legend style='font:bold 16pt arial;color:#002e5b;'>Reseller Form</legend>
<br/>
<table id='custform'>
 <colgroup><col width='35%'/><col width='65%'/></colgroup>
 <tr><th> Email :</th><td><%= cust.getEmail() %></td>
 </tr>
 <tr><th>Password :</th>
 <td><input type='password' name='Password' size='30' maxlength='15' value='<%= cust.getPassword() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Confirm Password :</th>
 <td><input type='password' name='vPassword' size='30' maxlength='15' value='<%= vpassword %>' onchange='checkPassword();'/></td>
 </tr>
 <tr><th>Company Name :</th>
 <td><input type='text' name='billingCompany' size='30' maxlength='40' value='<%= cust.getBilling().getCompany() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Reseller Certificate #</th>
 <td><input type='text' name='resellerCode' size='30' maxlength='15' value='<%= cust.getResellerCode() %>' onchange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>First Name :</th>
 <td><input type='text' name='billingFirstName' size='30' maxlength='25' value='<%= cust.getBilling().getFirstName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Last Name :</th>
 <td><input type='text' name='billingLastName' size='30' maxlength='25' value='<%= cust.getBilling().getLastName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Address1 :</th>
 <td><input type='text' name='billingAddress1' size='30' maxlength='40' value='<%= cust.getBilling().getAddress1() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Address2 :</th>
 <td><input type='text' name='billingAddress2' size='30' maxlength='40' value='<%= cust.getBilling().getAddress2() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr>
  <th>Country :</th>
  <td>
   <select name='billingCountry' style='width:205px;'>
    <%= advertShow.getCountryList(cust.getBilling().getCountry()) %>
   </select>
  </td>
 </tr>
 <tr><th>City/Locality :</th>
  <td><input type='text' name='billingCity' size='30' maxlength='30' value='<%= cust.getBilling().getCity() %>'/></td>
 </tr>
 <tr><th>State :</th>
  <td>
   <select name='billingState' style='width:205px;'>
    <option value=''/>
    <%= advertShow.getAllStateList(cust.getBilling().getState()) %>
   </select>
  </td>
 </tr>
 <tr><th>Postal/Zip Code :</th>
  <td>
   <input type='text' name='billingZip' size='10' maxlength='10' value='<%= cust.getBilling().getZip() %>' onChange='this.value=toAlphaNumeric(this.value);'/> <b>-</b>
   <input type='text' name='billingZip4' size='4' maxlength='4' value='<%= cust.getBilling().getZip4() %>' onChange='this.value=toAlphaNumeric(this.value);'/>
  </td>
 </tr>
 <tr><th>Phone :</th>
  <td><input type='text' name='billingPhone' size='30' maxlength='20' value='<%= cust.getBilling().getPhone() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Cell :</th>
  <td><input type='text' name='billingCell' size='30' maxlength='20' value='<%= cust.getBilling().getCell() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><th>Fax :</th>
  <td><input type='text' name='billingFax' size='30' maxlength='20' value='<%= cust.getBilling().getFax() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
 </tr>
 <tr><td colspan='2' style='font:bold 8pt arial;color:#800000;padding:0 0 0 18px;'>Comments :</td></tr>
 <tr>
  <td colspan='2' align='center'><textarea cols='58' rows='5' name='notice' onChange='this.value=toAlphaNumeric(this.value);'><%= cust.getNotice() %></textarea></td>
 </tr>
</table>
</fieldset>
</div>
<br/>
<input type='submit' name='mode' value='Send Form'/>
</form>

    </td>
    <td id='cvcenter' align="center" valign="top">


    </td>
    <td id='cvright' valign="top">&nbsp;</td>
   </tr>
  </tbody>
  </table>
 </div>

 <div id='cvfoot'></div>
</div>

</body>
</html>
